package com.ruoyi.flink.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.flink.domain.IpStatus;
import com.ruoyi.flink.service.IIpStatusService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * web服务运行ipController
 * 
 * @author shu_k
 * @date 2021-04-23
 */
@RestController
@RequestMapping("/flink/IpStatus")
public class IpStatusController extends BaseController
{
    @Autowired
    private IIpStatusService ipStatusService;

    /**
     * 查询web服务运行ip列表
     */
    @PreAuthorize("@ss.hasPermi('flink:IpStatus:list')")
    @GetMapping("/list")
    public TableDataInfo list(IpStatus ipStatus)
    {
        startPage();
        List<IpStatus> list = ipStatusService.selectIpStatusList(ipStatus);
        return getDataTable(list);
    }

    /**
     * 导出web服务运行ip列表
     */
    @PreAuthorize("@ss.hasPermi('flink:IpStatus:export')")
    @Log(title = "web服务运行ip", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(IpStatus ipStatus)
    {
        List<IpStatus> list = ipStatusService.selectIpStatusList(ipStatus);
        ExcelUtil<IpStatus> util = new ExcelUtil<IpStatus>(IpStatus.class);
        return util.exportExcel(list, "web服务运行ip数据");
    }

    /**
     * 获取web服务运行ip详细信息
     */
    @PreAuthorize("@ss.hasPermi('flink:IpStatus:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ipStatusService.selectIpStatusById(id));
    }

    /**
     * 新增web服务运行ip
     */
    @PreAuthorize("@ss.hasPermi('flink:IpStatus:add')")
    @Log(title = "web服务运行ip", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IpStatus ipStatus)
    {
        return toAjax(ipStatusService.insertIpStatus(ipStatus));
    }

    /**
     * 修改web服务运行ip
     */
    @PreAuthorize("@ss.hasPermi('flink:IpStatus:edit')")
    @Log(title = "web服务运行ip", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IpStatus ipStatus)
    {
        return toAjax(ipStatusService.updateIpStatus(ipStatus));
    }

    /**
     * 删除web服务运行ip
     */
    @PreAuthorize("@ss.hasPermi('flink:IpStatus:remove')")
    @Log(title = "web服务运行ip", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ipStatusService.deleteIpStatusByIds(ids));
    }
}
